#pragma once
#include "Comm.hpp"
class Init
{
public:
    Init()
    {
        CreateFifo();        
    }
    void CreateFifo()
    {
        int ret = mkfifo(filename,gmode);
        if (ret < 0) exit(1);
        std::cout << "make fifo sucess" << std::endl;
    }
    ~Init()
    {
        unlink(filename);
        std::cout << "unlink sucess" << std::endl;
    }
};

Init init;

class Server //读
{
public:
    Server()
        :_fd(gdefault)
    {
        
    }
    bool OpenForead()
    {
        _fd = open(filename,O_RDONLY);
        if (_fd < 0) return false;
        return true; 
    }
    int Recieve(std::string& out)
    {
        char buff[gsize];
        int n = read(_fd,buff,gsize);
        out = buff;
        return n;
    }

    ~Server()
    {}
private:
    int _fd;
};
